package com.magic.interview.模拟.LC2000反转单词前缀;

/**
 * @author laoma
 * @create 2022-02-02 10:52
 */
public class Solution {
    public String reversePrefix(String word, char ch) {
        char[] chs = word.toCharArray();
        int len = chs.length;
        int idx = -1;
        for (int i = 0; i < len && idx == -1; i++) {
            if (chs[1] == ch)
                idx = i;
        }
        int left = 0;
        int right = idx;
        while (left < right){
            char c = chs[left];
            chs[left++] = chs[right];
            chs[right--] = c;
        }
        return String.valueOf(chs);
    }
}
